//
//  AllThemeCollectionViewCell.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/8.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "AllThemeCollectionViewCell.h"
@interface AllThemeCollectionViewCell ()
@property (nonatomic, strong) UIImageView *backImage;
@property (nonatomic, strong) UIVisualEffectView *effectView;
@property (nonatomic, strong) UILabel *topLabel;
@property (nonatomic, strong) UILabel *midLabel;
@property (nonatomic, strong) UILabel *downLabel;
@end
@implementation AllThemeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        

//        self.backgroundColor = [UIColor redColor];
        self.backImage = [UIImageView new];
        self.backImage.layer.cornerRadius = self.height / 30;
        self.backImage.layer.masksToBounds = YES;

        [self addSubview:self.backImage];
        
        self.effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
        self.effectView.alpha = 0.3;
        [self.backImage addSubview:self.effectView];
        
        self.topLabel = [UILabel new];
        self.topLabel.textAlignment = NSTextAlignmentCenter;
        [self.topLabel setFont:[UIFont fontWithName:@"FZLanTingHei-EL-GBK" size:18]];
        self.topLabel.textColor = [UIColor whiteColor];
        [self addSubview:self.topLabel];
        
        self.midLabel = [UILabel new];
        self.midLabel.textAlignment = NSTextAlignmentCenter;
        [self.midLabel setFont:[UIFont fontWithName:@"FZLanTingHei-EL-GBK" size:16]];
        self.midLabel.text = @"————————∝————————";
        self.midLabel.textColor = [UIColor whiteColor];
        [self addSubview:self.midLabel];
        
        self.downLabel = [UILabel new];
        self.downLabel.textColor = [UIColor whiteColor];
        [self.downLabel setFont:[UIFont fontWithName:@"FZLanTingHei-EL-GBK" size:16]];
        self.downLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.downLabel];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    
    self.backImage.frame = CGRectMake(5, 5, self.width - 10, self.height - 10);
    self.effectView.frame = CGRectMake(0, 0, self.backImage.width, self.backImage.height);
    self.topLabel.frame = CGRectMake(self.backImage.left, self.height / 2 - self.height / 5, self.backImage.width, self.height / 7);
    self.midLabel.frame = CGRectMake(self.topLabel.left, self.topLabel.bottom, self.topLabel.width, self.topLabel.height / 2);
    self.downLabel.frame = CGRectMake(self.midLabel.left, self.midLabel.bottom, self.midLabel.width, self.topLabel.height);
}

- (void)setModel:(CXClassProModel *)model {
    if (self.model != model) {
        if (model) {
            [self.backImage sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url]];
            self.topLabel.text = model.title;
            self.downLabel.text = model.subtitle;
        }
    }
}

@end
